package com.zfl;

public class ClimbStairs {

    public static void main(String[] args) {
        int n = 5;
        int num = new ClimbStairs().climbStairs(n);
        System.out.println("num = " + num);
    }


    public int climbStairs(int n) {
        if (n==1) {
            return 1;
        }
        if (n==2){
            return 2;
        }
        int prev = 2;
        int prevPrev = 1;
        int cur = 0;


        for (int i = 3; i <= n ; i++) {
            cur = prevPrev+prev;
            prevPrev = prev;
            prev=cur;
        }
        return cur;

    }
}
